﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Linq.Expressions;
using System.Xml;
using RedSand.Web.Language;

namespace RedSand.Site
{

    public static class DropDownListHelper
    {
        #region status
        public static SelectList GetStatusList(bool all)
        {
            return GetStatusList(all, null);
        }
     
        public static SelectList GetStatusList(bool all, object selectValue)
        {
            List<SelectListItem> list = new List<SelectListItem>();
            if (all)
            {
                list.Add(new SelectListItem { Text = "", Value = "" });
            }
            list.Add(new SelectListItem { Text = "Active", Value = "1" });
            list.Add(new SelectListItem { Text = "InActive", Value = "2" });
            return new SelectList(list, "Value", "Text");
        }
        public static MvcHtmlString GetStatusString(object status)
        {
            string value = (Convert.ToByte(status) == 0 ? "" : status.ToString());
            var result = GetStatusList(true).Where(item => item.Value == value);
            return MvcHtmlString.Create(result.Count() == 0 ? "" : result.First().Text);
        }
        #endregion

        
        #region order
        public static SelectList GetOrderList(int totalRecord)
        {
            return GetOrderList(totalRecord, null);
        }
        public static SelectList GetOrderList(int totalRecord, object selectValue)
        {
            List<SelectListItem> list = new List<SelectListItem>();
            for (int i = 1; i <= totalRecord; i++)
            {
                list.Add(new SelectListItem { Text = i.ToString(), Value = i.ToString() });
            }
            return new SelectList(list, "Value", "Text", selectValue);
        }
        #endregion

    }
}
